package screen;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Screen {
    private VRAM vram = new VRAM();
    private int currentLine = -1;
    public void print(String s) {
        vram.setElem(currentLine, vram.getElem(currentLine) + s);
        vram.repaint();
        vram.revalidate();
    }
    public void discard() {
        vram.setElem(currentLine, vram.getElem(currentLine).substring(0, vram.getElem(currentLine).length() - 1));
        vram.repaint();
        vram.revalidate();
    }
    public void discardLine() {
        vram.doRemove(currentLine);
        currentLine--;
        vram.repaint();
        vram.revalidate();
    }
    public void println(String s) {
        currentLine++;
        vram.doAdd(s);
        if (vram.getCurrentSize() > vram.getMaxSize()) {
            vram.doRemove(0);
            vram.repaint();
            vram.revalidate();
            currentLine--;
        }
        vram.repaint();
        vram.revalidate();
    }
    public void clear() {
        vram.clear();
        currentLine = -1;
        vram.repaint();
        vram.revalidate();
    }
    public VRAM getVRAM() {
        return vram;
    }
}